package com.famous.springstudy.factory;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

import com.famous.springstudy.bean.User;

public class BeanFactoryStudy {

	public static void main(String[] args) {
		Resource resource = new ClassPathResource("spring/application-bean.xml");
		BeanFactory beanFactory = new XmlBeanFactory(resource);
		User user = (User) beanFactory.getBean("user");
		System.err.println(user.getName());
	}

	public void test() {
		DefaultListableBeanFactory beanFacory = new DefaultListableBeanFactory();
		XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFacory);
		reader.loadBeanDefinitions(new ClassPathResource("bean.xml"));
		User user = (User) beanFacory.getBean("user");
		System.err.println(user.getName());
	}
}
